package com.xcity.pomelo.response;

import java.util.ArrayList;
import java.util.List;

import com.xcity.db.entity.Player;
import com.xcity.game.activity.newplayer.ActivityNewPlayerService;
import com.xcity.game.activity.newplayer.NewPlayerTask;
import com.xcity.pomelo.response.ActivityNewPlayerInfoResponse.DayShopItem;

import naga.x.game.time.TimeUpdater;
import naga.x.net.impl.pomelo.PomeloMessage;
import naga.x.net.impl.pomelo.protocol.Message;
import naga.x.util.TimeUtils;

@PomeloMessage(type = Message.Type.RESPONSE)
public class ActivityNewPlayerDayShopListResponse extends Response {
	public long endSecond;
	public List<DayShopItem> dayShopList;
	public ActivityNewPlayerDayShopListResponse(int serial, Player player) {
		super(serial);
		int today = TimeUpdater.getInstance().today();
		int currentDay = TimeUtils.getDayGap(player.getNewPlayerTasks().getCreatDay(), today) + 1;//today - player.getNewPlayerTasks().getCreatDay() + 1;
		this.endSecond = player.getNewPlayerTasks().getRewardEndSecond();
		dayShopList = new ArrayList<DayShopItem>();
		for(int i = 1; i <= ActivityNewPlayerService.COUNT_DAY; i++){
			if(currentDay >= i){
				List<NewPlayerTask> taskList = player.getNewPlayerTasks().getTaskListByDay(i);
				for(int j = 0; j < taskList.size(); j++){
					NewPlayerTask task = taskList.get(j);
					byte type = task.getTemplate().getType();
					if(task.getTemplate().getBan() != 1){
						if(type == ActivityNewPlayerService.FUNC_TYPE_DAY_SHOP){
							DayShopItem dayShopItem = new DayShopItem(task);
							dayShopList.add(dayShopItem);
						}
					}
				}
			}
		}
	}

}
